let context = null
const initContext = (vue) => {
	context = vue;
}


// ----------------------------------------
//催单处理
const WOPushAsync = async (UserPhone,WOGUID,Remark,token)=>{
	let IdentifyId = "WOPush";
	var objects = {
		'UserId':UserPhone,
		'WOGUID':WOGUID,
		'Remark':Remark,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//返工
const WOReworkAsync = async (UserPhone,WOGUID,ReasonCodeId,Remark,token)=>{
	let IdentifyId = "WORework";
	var objects = {
		'UserId':UserPhone,
		'WOGUID':WOGUID,
		'ReasonCodeId':ReasonCodeId,
		'Remark':Remark,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}




//服务历程
const WOTraceAsync = async (UserPhone,WOGUID,token)=>{
	let IdentifyId = "WOTrace";
	var objects = {
		'UserId':UserPhone,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》地址列表（省或市或区）
const AddressListAsync = async (UserPhone,IdentifyName,FilterId,token)=>{
	let IdentifyId = "AddressList";
	var objects = {
		'UserId':UserPhone,
		'IdentifyName':IdentifyName,
		'FilterId':FilterId,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 完工页面=》保养完工=》滤芯信息接口
const GetFilterInfoAsync = async (UserPhone,token)=>{
	let IdentifyId = "GetFilterInfo";
	var objects = {
		'UserId':UserPhone,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》保养完工=》保养滤芯接口
// IsComfirmed Bool 类型
const GetPartsMaintainInfoAsync = async (UserPhone,PurchaseDate,CustEquipmentGuid,IsComfirmed,ProductGuid,token)=>{
	let IdentifyId = "GetPartsMaintainInfo";
	var objects = {
		'UserId':UserPhone,
		'PurchaseDate':PurchaseDate,
		'CustEquipmentGuid':CustEquipmentGuid,
		'IsComfirmed':IsComfirmed,
		'ProductGuid':ProductGuid,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}



//完工页面=》确认产品
const ConfirmProductAsync = async (UserPhone,WoFinishType,Barcode,ProductId,WoObjectId,WoId,PurchaseDate,token)=>{
	let IdentifyId = "ConfirmProduct";
	var objects = {
		'UserId':UserPhone,
		'WoFinishType':WoFinishType,
		'Barcode':Barcode,
		'ProductId':ProductId,
		'WoObjectId':WoObjectId,
		'WoId':WoId,
		'PurchaseDate':PurchaseDate,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}






// 完工页面=》维修页面=》整机保修信息
const GetProductMaintainceAsync = async (UserPhone,CustEquiptId,ProductId,PurchaseDate,IsConformed,token)=>{
	let IdentifyId = "GetProductMaintaince";
	var objects = {
		'UserId':UserPhone,
		'CustEquiptId':CustEquiptId,
		'ProductId':ProductId,
		'PurchaseDate':PurchaseDate,
		'IsConformed':IsConformed,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 完工页面=》维修页面=》整机保修信息
const ReplaceFilterByPartsNumAsync = async (UserPhone,KeyWords,WOGUID,token)=>{
	let IdentifyId = "ReplaceFilterByPartsNum";
	var objects = {
		'UserId':UserPhone,
		'KeyWords':KeyWords,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 完工页面=》保养页面=》搜索换件滤芯
const ReplaceFilterByKeyWordAsync = async (UserPhone,KeyWords,WOGUID,token)=>{
	let IdentifyId = "ReplaceFilterByKeyWord";
	var objects = {
		'UserId':UserPhone,
		'KeyWords':KeyWords,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

// 服务工单列表页面=》上门里程
const OnSiteDistanceAsync = async (ServiceOrderId,Latitude,Longitude,token)=>{
	let IdentifyId = "OnSiteDistance";
	var objects = {
		'ServiceOrderId':ServiceOrderId,
		'Latitude':Latitude,
		'Longitude':Longitude,
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

//完工页面=》保养页面=》通过保养件编号获取保养信息
const GetMaintainPartInfoByPartNum = async(UserPhone,KeyWords,WOGUID,token)=>{
	let IdentifyId = "ReplaceFilterByPartsNum";
	let objects = {
		'UserId':UserPhone,
		'KeyWords':KeyWords,
		'WOGUID':WOGUID,
	};
	let strObject = JSON.stringify(objects);
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}



// 主页=》获取滑动图片
const HPSlideImgsAsync = async (UserPhone,UpdateDateTime,token)=>{
	let IdentifyId = "HPSlideImgs";
	var objects = {
		'UserId':UserPhone,
		'UpdateDateTime':UpdateDateTime,
		'ClientType':"wechat"
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}
const GetMsgList = async(UserPhone,pageNum,pageSize,token)=>{
	let IdentifyId = "GetMsgList";
	var objects = {
		'UserId':UserPhone,
		'pageNum':pageNum,
		'pageSize':pageSize
	};
	let strObject = JSON.stringify(objects);	
	let [error, result]  = await context.commService.postEntityAsync(IdentifyId,strObject,token);
	if(!error && result.statusCode == 200){
		return result.data;
	}
	return null;
}

const testService = {
	initContext,
	WOPushAsync,
	WOReworkAsync,
	WOTraceAsync,
	AddressListAsync,
	GetFilterInfoAsync,
	GetPartsMaintainInfoAsync,
	ConfirmProductAsync,
	GetProductMaintainceAsync,
	ReplaceFilterByPartsNumAsync,
	ReplaceFilterByKeyWordAsync,
	OnSiteDistanceAsync,
	HPSlideImgsAsync,
	GetMsgList,
}


export default testService